home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 November: Tool Chest / Dev.CD Nov 96 TC / Dev.CD Nov 96 TC.toast / What's New? / Development Kits / Apple Game Sprockets / NetSprocket 1.0.1 / NetSprocketTest Sources / NSTestApp.h < prev   
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.8 KB  |  113 lines  |  [TEXT/CWIE]

  1.  
  2. #pragma once
  3.  
  4. #include <LApplication.h>
  5.  
  6. #include "NetSprocket.h"
  7. #include <LArray.h>
  8. #include <LComparator.h>
  9. #include <LWindow.h>
  10.  
  11. typedef struct TKeyState
  12. {
  13.     NSpMessageHeader    h;
  14.     UInt32                keyMap[4];
  15.     UInt32                pulseBit;
  16. } TKeyState;
  17.  
  18. typedef struct OptionsMessage
  19. {
  20.     NSpMessageHeader    header;
  21.     UInt32                priority;
  22.     UInt32                rate;
  23.     UInt32                size;
  24. } OptionsMessage;
  25. UInt32 gPulseBit;
  26.  
  27. typedef struct PlayerListItem
  28. {
  29.     NSpPlayerID    player;
  30.     LWindow        *window;
  31. } PlayerListItem;
  32.  
  33. class CPlayerListComparator : LComparator
  34. {
  35. public:
  36.     CPlayerListComparator() {}
  37.     ~CPlayerListComparator() {}
  38.     virtual Int32        Compare(
  39.                                 const void*            inItemOne,
  40.                                 const void*         inItemTwo,
  41.                                 Uint32                inSizeOne,
  42.                                 Uint32                inSizeTwo) const;
  43.                                 
  44.     virtual Boolean        IsEqualTo(
  45.                                 const void*            inItemOne,
  46.                                 const void*         inItemTwo,
  47.                                 Uint32                inSizeOne,
  48.                                 Uint32                inSizeTwo) const;
  49.     virtual    Int32        CompareToKey(
  50.                                 const void*            inItem,
  51.                                 Uint32                inSize,
  52.                                 const void*            inKey) const;
  53.                                 
  54.     virtual    Boolean        IsEqualToKey(
  55.                                 const void*            inItem,
  56.                                 Uint32                inSize,
  57.                                 const void*            inKey) const;
  58.  
  59.  
  60. };
  61.  
  62.  
  63. class    NSTestApp : public LApplication {
  64. public:
  65.                         NSTestApp();        // constructor registers all PPobs
  66.     virtual             ~NSTestApp();        // stub destructor
  67.     
  68.         // this overriding function performs application functions
  69.         
  70.     virtual void        ProcessNextEvent(void);
  71.     virtual Boolean        ObeyCommand(CommandT inCommand, void* ioParam);    
  72.     
  73.         // this overriding function returns the status of menu items
  74.         
  75.     virtual void        FindCommandStatus(CommandT inCommand,
  76.                             Boolean &outEnabled, Boolean &outUsesMark,
  77.                             Char16 &outMark, Str255 outName);
  78. protected:
  79.  
  80.     virtual void        StartUp();        // overriding startup functions
  81.             void        HandleGameEvent(NSpMessageHeader *inEvent);
  82.             void        HandlePlayerJoined(NSpPlayerJoinedMessage *inEvent);
  83.             void        HandlePlayerLeft(NSpPlayerLeftMessage *inEvent);
  84.             void        HandleGameStart(NSpMessageHeader *inEvent);
  85.             void        HandleGamePause(NSpMessageHeader *inEvent);
  86.             void        HandleGameEnd(NSpMessageHeader *inEvent);
  87.             void        HandleGameTerminated(NSpGameTerminatedMessage *inMessage);
  88.             void        HandleTestGroups(NSpMessageHeader *inEvent);
  89.             void        HandleKeyboardState(TKeyState *inEvent);
  90.             void        HandleResyncMessage(TKeyState *inEvent);
  91.             void        HandlePropogateOptions(OptionsMessage *inEvent);
  92.             
  93.             void        DoHost(void);
  94.             void        DoJoin(void);
  95.             void        DoGetGroups(void);
  96.             void        DoGetPlayers(void);
  97.             void        DoTestGroups(void);
  98.             void        DoUnadvertise(void);
  99.             void        DoStartGame(void);
  100.             void        DoGameEnd(void);
  101.     virtual    void        DoKillGame(void);
  102.             void        DoResetOptions(void);
  103.             void        DoPropogateOptions(void);
  104.             void        DoSendResyncMessage(void);
  105.             
  106.     NSpGameReference        theGame;
  107.     Boolean                bAdvertising;
  108.     Boolean                bHost;
  109.     Boolean                bRunning;
  110.     NSpPlayerID            mPlayerID;
  111.     LArray                *mPlayerList;            
  112.     
  113. };